﻿using System;
using System.IO;
using System.Net;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LKCMS.Common;

namespace LKCMS.Web.Admin.IM
{
    public partial class Edit : LKCMS.Web.UI.ManagePage
    {
        public int Id;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!int.TryParse(Request.QueryString["id"] as string, out this.Id))
            {
                JscriptMsg(350, 230, "错误提示", "<b>出现错误啦！</b>您要修改的信息不存在或参数不正确。", "back", "Error");
                return;
            }
            if (!Page.IsPostBack)
            {
                chkLoginLevel("editIM");
                //绑定类别
                ShowInfo(this.Id);
            }
        }

        //赋值操作
        private void ShowInfo(int _id)
        {
            LKCMS.BLL.IM bll = new LKCMS.BLL.IM();
            LKCMS.Model.IM model = bll.GetModel(_id);

            this.txtIMAccount.Text = model.IMAccount;
                this.txtIMName.Text=model.IMName;
                    txtSortId.Text=model.SortId.ToString();
                    this.rblIMType.SelectedValue = model.IMType;
                    this.rblIsLock.SelectedValue = model.Islock.ToString();
        }

        //保存
        protected void btnSave_Click(object sender, EventArgs e)
        {

            LKCMS.BLL.IM bll = new LKCMS.BLL.IM();
            LKCMS.Model.IM model = bll.GetModel(this.Id);
            model.IMName = txtIMName.Text.Trim();
            model.IMAccount = txtIMAccount.Text.Trim();
            model.IMType = rblIMType.SelectedItem.Text;
            model.Islock = int.Parse(rblIsLock.SelectedItem.Value);
            model.SortId = int.Parse(this.txtSortId.Text.Trim());
            bll.Update(model);
            //保存日志
            SaveLogs("[IM模块]编辑IM：" + model.IMAccount);

            JscriptPrint("编辑IM成功啦！", "List.aspx", "Success");
        }

    }
}
